package com.mhg.collection.theList;

public class Main3 {

    public static void main(String[] args) {
        char[] arr1 = {'0'};
        char[] arr2 = {'2','5','5'};
        char[] arr3 = {'2','5','6'};
        isRight(arr1);
        isRight(arr2);
        isRight(arr3);
    }

    public static void isRight(char[] arr){
        boolean flag = true;
        if (arr.length>4 ){
            flag=false;
        }else if(arr.length==3 && arr[0]>'2'){
            flag=false;
        }else if(arr.length==3 && arr[0]=='2' && arr[1]>'5'){
            flag=false;
        }else if(arr.length==3 && arr[0]=='2' && arr[1]=='5' && arr[2]>'5'){
            flag=false;
        }
        for (char c : arr){
            if (c <'0' || c>'9'){
                flag = false;
            }
        }
        String str = new String(arr);
        System.out.println(str + " 是合法数组吗？ " + flag );
    }
}
